package com.eastfair.certificate.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.annotation.annotation.security.PreAuth;
import com.eastfair.boot.controller.SuperController;
import com.eastfair.boot.request.PageParams;
import com.eastfair.certificate.dao.BusinessMapper;
import com.eastfair.certificate.dto.BlacklistPageQuery;
import com.eastfair.certificate.dto.BlacklistSaveDTO;
import com.eastfair.certificate.dto.BlacklistUpdateDTO;
import com.eastfair.certificate.dto.StatisticsDTO;
import com.eastfair.certificate.entity.Blacklist;
import com.eastfair.certificate.service.BlacklistService;
import com.eastfair.certificate.vo.BlacklistVO;
import com.eastfair.core.base.R;
import com.eastfair.core.context.ContextUtil;
import com.eastfair.echo.core.EchoService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * <p>
 * 前端控制器
 * 
 * </p>
 *
 * @author ligang
 * @date 2022-08-02
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/statistics")
@Api(value = "StatisticsController", tags = "")
public class StatisticsController  {

    @Autowired
    private EchoService echoService;
    @Autowired
    private BusinessMapper businessMapper;


    /**
     * @Author ligang
     * @Description 统计证件数量+ 领取证件数
     * @Date 11:17 2022/8/2
     * @Param [query]
     * @return
     **/
    @PostMapping("/queryCertificateNum")
    public R<Map> queryCertificateNum(@RequestBody StatisticsDTO statisticsDTO){
        return R.success(businessMapper.queryCertificateNum(statisticsDTO));
    }


    /**
     * @Author ligang
     * @Description 统计证件类型统计
     * @Date 11:17 2022/8/2
     * @Param [query]
     * @return
     **/
    @PostMapping("/queryCertificateNumOfType")
    public R<List<Map>> queryCertificateNumOfType(@RequestBody StatisticsDTO statisticsDTO){
        return R.success(businessMapper.queryCertificateNumOfType(statisticsDTO));
    }



    /**
     * @Author ligaing
     * @Description 统计证件状态统计
     * @Date 11:17 2022/8/2
     * @Param [query]
     * @return
     **/
    @PostMapping("/queryCertificateNumOfOrderStatus")
    public R<List<Map>> queryCertificateNumOfOrderStatus(@RequestBody StatisticsDTO statisticsDTO){
        return R.success(businessMapper.queryCertificateNumOfOrderStatus(statisticsDTO));
    }


    /**
     * @Author ligang
     * @Description 统计订单
     * @Date 11:17 2022/8/2
     * @Param [query]
     * @return
     **/
    @PostMapping("/queryNumOfOrderNum")
    public R<List<Map>> queryNumOfOrderNum(@RequestBody StatisticsDTO statisticsDTO){
        return R.success(businessMapper.queryNumOfOrderNum(statisticsDTO));
    }
}
